package com.woniuxy.woniumall.controller;

import com.github.pagehelper.PageInfo;
import com.woniuxy.woniumall.entity.Catagory;
import com.woniuxy.woniumall.service.CatagoryService;
import com.woniuxy.woniumall.vo.BookVo;
import com.woniuxy.woniumall.vo.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("catagory")
public class CatagoryController {

    @Autowired
    CatagoryService catagoryService ;

    @GetMapping("/list")
    @ResponseBody
    public ResponseResult<List<Catagory>> list(){
        ResponseResult<List<Catagory>> result = new ResponseResult<>();
        try {
            List<Catagory> list = catagoryService.findAllCatagory();
            result.setCode(200);
            result.setMsg("查询成功！");
            result.setData(list);
        }catch (Exception e) {
            e.printStackTrace();
            result.setCode(201);
            result.setMsg("查询失败!");
        }
        return result ;
    }
}
